home *** CD-ROM | disk | FTP | other *** search
-
-
- SiFLyiNG
- Tutorial #5
-
- ____________________________________________________________________________
-
- Target : AfKayAs CrackMe #1
- d/l it on EB site http://crackmes.cjb.net
- Protection type : Serial/Name, VB
- Tools needed : SoftIce, Windasm, Basis of VB cracking & functions
- ____________________________________________________________________________
-
- Before beginning...
-
- This crackme is based on a simply serial/name protection. The serial
- is calculated with your name and the routine is not very difficult. First
- we'll see how to find a serial in a minute and then we'll see the routine
- wich calculates the serial from your name, so that you'll be able to code
- your own keygen. Time is money, so let's start !
-
- ____________________________________________________________________________
-
- The essay...
-
- 1. The serial
-
- If you disassemble this crackme with Windasm, you'll see that it's coded
- with VB5. Look in the imports to find an entry point in the code. You
- should find interested functions like : __vbaStrCmp, __vbaLenBstr (returns the
- len of a string) or rtcMsgBox (displays a message in a dialog box).
- So, we could try the classic comparison call: __VbStrCmp, which would be
- the best way (i think) to find a valid serial. Let's enter a name: 'SiFLyiNG'
- and a serial :'12345678'. Press the 'OK' button and you're back in SoftIce:
-
- 'Break due to BPX MSVBVM50!__vbaStrCmp'
-
- Return to the caller with F11 and you should see:
-
- :402533 Call [MSVBVM50!__vbaStrCmp]
- :402539 MOV ESI, EAX
-
- Eax contains what the comparison function has returned when comparing
- the valid code and our code. In our case Eax = FFFF FFFF but when our code
- is the valid code, it returns Eax = 0000 0000. That will be useful for the
- jz Good Guy at line 40258B which will jump if Eax = 0, ie if the both code
- (ours and the valid generated by the crackme) are the same. But in our case
- it'll return FFFFFFFF so they'll be no jump and a MessageBox : 'You get wrong'
- But the aim of the crackme is not to patch but to find a valid serial.
- So, we're back to the comparison : if you trace up a bit you'll see :
-
- :402532 Push Eax
- :402533 Call [MSVBVM50!__vbaStrCmp]
- :402539 MOV ESI, EAX
-
- Thus, we can suppose that Eax contains the adress where the valid code
- is stored. Let's try ! BPX on this line : either double click on it, or
- 'bpx 402532'. Back to Win. Press ok : the line is highlighted. Let's try a
- 'd eax'. Hummm, we see : AKA-780331. I bet it's the valid serial ;)
- Disable your breakpoints and exit SoftIce. Enter the string, press
- the 'OK' button : 'You get it. Keygen it now.'
-
- Ok, the crackme is cracked. But we won't stop there ! Let's keygen it,
- as the author, AfKayAs asked.
-
- 2. The keygen
-
- To find the calculation routine, we'll try to enter in the code with
- SoftIce in a different way. Logically, the calculation routine is up
- to the comparison routine, so we'll see with WinDasm where we could break to
- find this routine. If you place yourself on the adress 402532 and you trace up,
- you will see call to VB functions like:
-
- - MSVBVM50.__vbaStrMove
- - MSVBVM50.__vbaStrCat
- - MSVBVM50.__vbaHresultCheckObj
-
- ...not very attractive... but if you trace up until 0040242D you'll see some
- very interesting calls :
-
- - MSVBVM50.__vbaLenBstr : returns the lenght of a string, and probably the lenght
- of the entered name here )
- - MSVBVM50.rtcAnsiValueBstr : i believe it returns the ascii value of a char
- ( when it's used with a string, it always returns the
- ascii code of the first char of the string)
-
- So, we could make a bpx on __vbaLenBstr in SoftIce. Press F11 and you arrive
- here :
-
- * Reference To: MSVBVM50.__vbaLenBstr, Ord:0000h
- |
- :00402415 Call dword ptr [004040E4] ;call to __vbaLenBstr
- :0040241B mov edi, eax ; the call returns the len of the name in eax
- ; so eax = 8 for 'SiFLyiNG' and edi = 8 too
- :0040241D mov ecx, dword ptr [ebp-18] ; 'd ecx' and you'll see the name
- :00402420 imul edi, 00017CFB ; edi = len * 17CFBh (h for hexa)
- :00402426 push ecx ; push the name on the stack (in wide characters)
- :00402427 jo 004026BE ; jump in case of overflow
-
- * Reference To: MSVBVM50.rtcAnsiValueBstr, Ord:0204h
- |
- :0040242D Call dword ptr [004040F8] ; call to rtcAnsiValueBstr
-
- ( the call returns the ascii code of the first char of the string the last
- pushed on the stack, wich here is the name, so it will return the ascii code
- the first char of our name in eax, here the code for 'S', 53h)
-
- :00402433 movsx edx, ax ; ax = 53h so edx = 0000 0053h
- :00402436 add edi, edx ; add edx to edi
- :00402438 jo 004026BE ; jump if overflow
- :0040243E push edi ; save edi
-
- But what does EDI contains ? Do '? EDI' and you'll see :
-
- EDI = BE82Bh = 780331
-
- Doesn't it remind you something ? Yes the code previously found was :
- 'AKA-780331'. Now you should understand. So, this little routine has
- calculated the second part of the keygen. Then, this part will be converted
- from hexadecimal to decimal, then converted to a string and finally added to
- the string 'AKA-'. Now we know what's necessary to make a keygen.
-
- Let's summarize :
-
- 1. it takesthe lenght of the name
- 2. the len is multiplied with the value 17CFBh
- 3. the ascii code of the first char of the name is added to the previous value
- calculated in 2.
- 4. the value is converted to decimal
- 5. the second part is converted to a string and added to 'AKA-'
-
- but we could make easier, directly in decimal base :
-
- 1. second_part=len_of_name * 97531 + ascii_code_of_the_first_char_of_the_name
- 2. serial = 'AKA-' & second_part
-
- so in QBasic it will make :
-
- INPUT "Name: "; username$
- serial$ = "AKA-" + RTRIM$(LTRIM$(STR$(LEN(username$) * 97531 + ASC(username$))))
- PRINT serial$
-
- and in VB :
-
- Serial = "AKA-" & Trim(Str(Len(username) * &H17CFB + Asc(username)))
-
- Of course you can make it with ASM, C++ and whatever you want !!!
-
- ____________________________________________________________________________
-
- The end...
-
- Voila, another crackme cracked and 'keygened'. I've tried to make it
- sufficiently understandable but if you have a problem, or if i made an error,
- a nonsense... just mail me.
-
- SiFLyiNG
- siflying@ifrance.com
-
- Greetz : Eternal Bliss, Acid Burn, Lucifer48, Carpathia, Skymarshall,
- and all the others that i don't know ...
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-